home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
util
/
cdity
/
Yak210src.lha
/
Yak_2.10_Src
/
Icon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-07
|
3KB
|
128 lines
/*
* Routines dealing with processing of Yak's icon
* (be they for tooltypes or AppIcon purposes).
*
* MWS, Tuesday 13-Oct-92
*/
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/wb.h>
#include <proto/icon.h>
#include <exec/types.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <string.h>
#include "icon.h"
struct MsgPort *AppMsgPort=NULL;
ULONG appsigflag=0L;
static struct DiskObject *diskobj;
__regargs BOOL
GetOurIcon(STRPTR name)
{
if (name)
{
/* Get Disk Object */
diskobj = GetDiskObject(name);
}
return (BOOL)(diskobj ? TRUE : FALSE);
}
/* can cope with multiple calls */
void
FreeOurIcon()
{
if (diskobj)
{
FreeDiskObject(diskobj);
diskobj = NULL;
}
}
/* like ArgString() */
__regargs char *
TTString(char *name, char *def)
{
char *what;
if (diskobj)
if (what = FindToolType(diskobj->do_ToolTypes, name))
return what;
return def;
}
/* like ArgInt() */
__regargs LONG
TTInt(char *name, LONG def)
{
char *what;
if (diskobj)
if (what = FindToolType(diskobj->do_ToolTypes, name))
StrToLong(what, &def);
return def;
}
/* simple extension to ArgXXX routines */
__regargs BOOL
TTBool(char *name, BOOL def)
{
char *s;
s = TTString(name, def ? "YES" : "NO");
return (BOOL)(((strcmp(s, "YES") == 0) ||
(strcmp(s, "TRUE") == 0) ||
(strcmp(s, "ON") == 0)) ? TRUE : FALSE);
}
#ifndef PREFS
static struct AppIcon *appicon;
/* create our AppIcon */
__regargs BOOL
MakeOurAppIcon(char *name)
{
if (diskobj)
if (AppMsgPort = CreateMsgPort())
{
diskobj->do_CurrentX = TTInt("ICONXPOS", NO_ICON_POSITION);
diskobj->do_CurrentY = TTInt("ICONYPOS", NO_ICON_POSITION);
if (appicon = AddAppIconA(0, 0L, name, AppMsgPort, 0L, diskobj, 0L))
{
appsigflag = 1 << AppMsgPort->mp_SigBit;
return TRUE;
}
else DeleteMsgPort(AppMsgPort);
}
return FALSE;
}
/* bye bye icon... */
void
RemoveOurAppIcon()
{
if (appicon) RemoveAppIcon(appicon);
if (AppMsgPort) DeleteMsgPort(AppMsgPort);
}
#endif
/* just clear the port */
void
ClearAppMsgPort()
{
struct Message *msg;
while (msg = GetMsg(AppMsgPort))
ReplyMsg(msg);
}